<template>
  <AppPage title="Home Page" :back="false">
    <div class="home">
      <div class="backup">
        <div class="backup-wrapper">
          <div class="backup-line left">
            <img src="@/assets/images/mobileUS.webp" alt="" />

            <img src="@/assets/images/mobileUS.webp" alt="" />
          </div>

          <div class="backup-line right">
            <img src="@/assets/images/mobileUS1.webp" alt="" />

            <img src="@/assets/images/mobileUS1.webp" alt="" />
          </div>
        </div>
      </div>

      <div class="wrapper">
        <div class="to-statr-btn" @click="toStartVideoChat">
          <img src="@/assets/images/video-fill.svg" alt="" />
          <span class="text">Start Video Chat</span>
        </div>
      </div>
    </div>
    <van-popup
      v-model:show="isSetRoomInfo"
      style="width: 80vw; padding: 30px 30px 40px 30px; border-radius: 15px"
    >
      <div class="popup-contain">
        <div class="title">与其他用户视频聊天</div>
        <div class="input">
          <div class="label">用户ID</div>
          <input
            type="text"
            v-model="contacterId"
            placeholder="输入受邀者的用户ID"
          />
        </div>
        <div class="input" v-if="false">
          <div class="label">房间号</div>
          <input
            type="text"
            v-model="roomId"
            placeholder="输入房间号"
          />
        </div>
        <div class="btn" @click="startChat">确定</div>
      </div>
    </van-popup>
    <VideoBox :show="isStartVideoChat" :localUserID="contacterId" :localRoomID="roomId" @exit="isStartVideoChat=false" />
  </AppPage>
</template>
<script setup lang="ts">
import AppPage from "@/components/AppPage.vue";
import VideoBox from "@/components/VideoBox.vue";
import { showToast } from 'vant';

import { ref } from "vue";
const contacterId = ref("");
const roomId = ref("0001");
const isSetRoomInfo = ref(false);
const isStartVideoChat = ref(false);

const toStartVideoChat = () => {
  console.log('sss')
  isSetRoomInfo.value = !isSetRoomInfo.value;
};

const startChat = () => {
  if (contacterId.value) {
    isSetRoomInfo.value = false;
    isStartVideoChat.value = true;
  } else {
    showToast('请输入信息')
    return false;
  }
};
</script>
<style lang="less" scoped>
.home {
  .wrapper {
    width: 80vw;
    position: fixed;
    bottom: 120px;
    left: 10vw;
    z-index: 15;

    .to-statr-btn {
      height: 54px;
      line-height: 54px;
      background: #fff;
      border-radius: 54px;
      color: #000;
      display: flex;
      justify-content: center;
      margin-top: 15px;
      cursor: pointer;
      font-weight: bold;
      img {
        height: 40px;
        margin-top: 7px;
        margin-right: 5px;
      }
    }
  }
  .backup {
    width: 100vw;
    height: calc(100vh - 60px);
    overflow: hidden;
    padding: 15px 0;
    background-color: rgba(20,20,20, 0.9);
    position: fixed;
    top: 0;
    left: 0;
    .backup-wrapper {
      display: flex;
      justify-content: space-between;
      .backup-line {
        display: flex;
        flex-direction: column;
        transform: translateY(0);
        img {
          width: calc(50vw + 5px);
          filter: brightness(70%);
        }
      }
      .backup-line.left {
        margin-left: -10px;
        animation: moveUp 40s linear infinite;
      }
      .backup-line.right {
        margin-right: -10px;
        animation: moveDown 40s linear infinite;
      }
    }
  }
}
.popup-contain {
  .title {
    color: #333;
    text-align: center;
    font-weight: bold;
    margin-bottom: 15px;
  }
  .input {
    display: flex;
    width: 100%;
    margin: 0 auto;
    margin-bottom: 15px;
    .label {
      width: 60px;
      font-size: 14px;
      color: #333;
      line-height: 36px;
    }
    input {
      outline: none;
      border: 1px solid #ddd;
      border-radius: 6px;
      padding: 0 5px;
      height: 36px;
      width: 100%;
      font-size: 14px;
      color: #000;
    }
  }
  .btn {
    margin-top: 20px;
    min-width: 100px;
    height: 40px;
    line-height: 40px;
    border-radius: 10px;
    background: #00f69d;
    font-size: 14px;
    font-weight: bold;
    color: #333;
  }
}
@keyframes moveUp {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}
@keyframes moveDown {
  0% {
    transform: translateY(-50%);
  }
  100% {
    transform: translateY(0);
  }
}
</style>
